package com.itqf.service.impl;

import com.itqf.mapper.DtsGoodsMapper;
import com.itqf.mapper.DtsGoodsProductMapper;
import com.itqf.mapper.DtsOrderMapper;
import com.itqf.mapper.DtsUserMapper;
import com.itqf.service.DashboardService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * projectName: sm_project
 *
 * @author: 赵伟风
 * time: 2021/7/14 15:11
 * description:首页展示接口实现类
 */
@Service
public class DashboardServiceImpl implements DashboardService {

    @Autowired
    private DtsUserMapper dtsUserMapper;
    @Autowired
    private DtsGoodsMapper dtsGoodsMapper;
    @Autowired
    private DtsGoodsProductMapper goodsProductMapper;
    @Autowired
    private DtsOrderMapper dtsOrderMapper;

    public static  final Logger logger = LoggerFactory.getLogger(DashboardServiceImpl.class);

    /**
     * 首页数据展示
     * 用户数据
     * 货物数据
     * 库存数据
     * 订单数据
     *
     * @return
     * "goodsTotal":426,
     * "userTotal":197,
     * "productTotal":8939,
     * "orderTotal":107
     */
    @Override
    public Map showDashboard() {

        Long goodsTotal = dtsGoodsMapper.queryTotal();
        Long userTotal = dtsUserMapper.queryTotal();
        Long productTotal = goodsProductMapper.queryTotal();
        Long orderTotal = dtsOrderMapper.queryTotal();

        logger.debug("[首页数量展示]查询货物数量:{},用户数量:{},库存数量:{},订单数量:{}", goodsTotal,userTotal,productTotal,orderTotal);

        Map data = new HashMap();
        data.put("goodsTotal", goodsTotal);
        data.put("userTotal", userTotal);
        data.put("productTotal", productTotal);
        data.put("orderTotal", orderTotal);

        logger.info("[首页数据展示]业务执行完毕!返回数据为:{}",data);

        return data;
    }
}
